package com.nineclock.attendance.controller;

import com.nineclock.api.attendance.AttendancePunchControllerApi;
import com.nineclock.attendance.dto.AttendPunchDTO;
import com.nineclock.attendance.dto.AttendPunchUserWholeDayDTO;
import com.nineclock.attendance.service.AttendancePunchService;
import com.nineclock.common.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AttendancePunchController implements AttendancePunchControllerApi {
    @Autowired
    AttendancePunchService attendancePunchService;
    /**
     * 移动端打卡
     * @param attendPunchDTO
     * @return
     */
    @PostMapping("/punch")
    @Override
    public Result punch(@RequestBody AttendPunchDTO attendPunchDTO) {
        attendancePunchService.punch(attendPunchDTO);
        return Result.success();
    }
    // 获取打卡数据
    @GetMapping("/get")
    @Override
    public Result<AttendPunchUserWholeDayDTO> getPunchData() {
        AttendPunchUserWholeDayDTO userWholeDayDTO = attendancePunchService.getPunchData();
        return Result.success(userWholeDayDTO);
    }
    // 查询考勤列表数据
    @GetMapping("/members")
    @Override
    public Result<List<AttendPunchDTO>> getMembers(String startTime, String endTime) {
        List<AttendPunchDTO> list = attendancePunchService.getMembers(startTime, endTime);
        return Result.success(list);
    }
    // 导入指定时间段考勤打卡数据
    @GetMapping("/export")
    @Override
    public Result export(String startTime, String endTime) {
        attendancePunchService.export(startTime, endTime);
        return Result.success();
    }
}
